<?php

namespace System\library\database\sql;

use System\library\database\sql\Sql;

/**
 * <b>Interface</b> :    IDriver<br>
 * <b>Fonction</b> :     Interface for all drivers database class
 * <br>
 * @version              1.0
 * @author               Steuf <dreadlokeur@gmail.com>
 * @license              Licence publique générale GNU http://www.gnu.org/licenses/gpl.html
 * @copyright            Copyright 2011 - MidichloriansPHP and contributors
 * @package              System
 * @subpackage           library\database\sql
 */
interface IDriver {

    /**
     * Construct object with the SqlConfig name
     *
     * @access public
     * @param string $config SqlConfig name
     * @return void
     */
    public function __construct($config);

    /**
     * Prepare a query to execute
     *
     * @access public
     * @param string $query a query
     * @return void
     */
    public function setQuery($query);

    /**
     * Bind parameter to query
     *
     * @access public
     * @param mixed $parameter
     * @param const $type
     * @param string $key
     * @return object Driver class
     */
    public function bindParam($parameter, $type, $key = false);

    /**
     * Execute the query
     * 
     * @access public
     * @return Void
     */
    public function execute();

    /**
     * Fetch result for query
     *
     * @access public
     * @param const $type
     * @return mixed
     */
    public function fetch($type= SQL::FETCH_OBJECT);

    /**
     * Fetch all result of query
     *
     * @access public
     * @param const $type
     * @return mixed
     */
    public function fetchAll($type = SQL::FETCH_OBJECT);

    /**
     * See the number of results of query
     * 
     * @access public
     * @return int
     */
    public function count();

    /**
     * Get the last id of INSERT query
     *
     * @access public
     * @return Int
     */
    public function getLastId();

    /**
     * Get number of affected row with query
     *
     * @access public
     * @return int
     */
    public function affectedRows();

    /**
     * Get the statement objet of query
     *
     * @access public
     * @return mixed a statement object or null
     */
    public function getStatement();

    /**
     * Free stored results of statement on memory
     *
     * @access public
     * @return void
     */
    public function free();

    /**
     * Get status informations of server
     *
     * @access public
     * @return string
     */
    public function status();

    /**
     * Close server connexion
     *
     * @access public
     * @return bool
     */
    public function disconnect();

    /**
     * Connect or reconnect server
     *
     * @access public
     * @param bool $master Set if must be a slave or a master server
     * @return void
     */
    public function connection();

    /**
     * Get metadatas for current query
     *
     * @access public
     * @return array
     */
    public function getMetaDatas();

    /**
     * Return an object with last error and last error number
     *
     * @access public
     * @return \stdClass $err->error && $err->numError
     */
    public function getLastError();
}

?>
